import { baseRequestClient, requestClient } from '#/api/request';

export namespace ProductSales {
  export interface Params {
    attr1: null;
  }
  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: null;
    remark: string;
    params: Params;
    salesId: number;
    salesCode: string;
    salesName: string;
    noticeId: number;
    noticeCode: string;
    soCode: string;
    clientId: number;
    clientCode: string;
    clientName: string;
    clientNick: string;
    recipient: string;
    tel: string;
    address: string;
    carrier: null;
    shippingNumber: null;
    salesDate: Date;
    status: string;
    attr2: null;
    attr3: number;
    attr4: number;
    attr1: boolean | null | string;
  }
  export interface GetListParams {
    pageNum: number;
    pageSize: number;
  }
  export interface GetListReturn {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

// 获取列表
export const getProductSalesTableList = (params: ProductSales.GetListParams) =>
  requestClient.get<ProductSales.GetListReturn>('/mes/wm/productsales/list', {
    params,
  });
// 增加销售出库单
export const addProductSales = (data: ProductSales.Row) =>
  requestClient.post<ProductSales.GetListReturn>('/mes/wm/productsales', data);

// 删除销售出库单
export const deleteProductSales = (id: string) =>
  requestClient.delete<ProductSales.GetListReturn>(
    `/mes/wm/productsales/${id}`,
  );

// 修改销售出库单
export const updateProductSales = (data: ProductSales.Row) =>
  requestClient.put<ProductSales.GetListReturn>('/mes/wm/productsales', data);

export const getProductSalesCode = () =>
  baseRequestClient.get<any>('/system/autocode/get/PRODUCTSALSE_CODE');
